package com.rule.front.api.drools;

import com.rule.drools.entity.ActionRuleRelEntity;
import com.rule.drools.service.ActionRuleRelService;
import com.rule.core.utils.PageUtils;
import com.rule.core.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 动作与规则信息关系表
 *
 * @author gz
 * @email 360568523@qq.com
 * @date 2019-05-25 14:54:38
 */
@RestController
@RequestMapping("rules/actionrulerel")
public class ActionRuleRelController {
    @Autowired
    private ActionRuleRelService actionRuleRelService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public Result list(@RequestParam Map<String, Object> params){
        PageUtils page = actionRuleRelService.queryPage(params);

        return Result.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{ruleActionRelId}")
    public Result info(@PathVariable("ruleActionRelId") Long ruleActionRelId){
		ActionRuleRelEntity actionRuleRel = actionRuleRelService.getById(ruleActionRelId);

        return Result.ok().put("actionRuleRel", actionRuleRel);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public Result save(@RequestBody ActionRuleRelEntity actionRuleRel){
		actionRuleRelService.save(actionRuleRel);

        return Result.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public Result update(@RequestBody ActionRuleRelEntity actionRuleRel){
		actionRuleRelService.updateById(actionRuleRel);

        return Result.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public Result delete(@RequestBody Long[] ruleActionRelIds){
		actionRuleRelService.removeByIds(Arrays.asList(ruleActionRelIds));

        return Result.ok();
    }

}
